﻿using System;
using System.Collections;
using UnityEngine;
namespace DefaultNamespace
{
    public class WWWTestGetTexture : MonoBehaviour
    {
        private Texture texture;
        void Start()
        {

        }

        private void Update()
        {

            if (Input.GetKeyDown(KeyCode.W))
            {
                Debug.Log("print something..");
                this.StartCoroutine(Testwww());
            }
        }
        //https://pics5.baidu.com/feed/b64543a98226cffc7a575253c59c0299f703ea7d.jpeg?token=4b0c5a54c8067c2b5760f5dee0e25aa0

        IEnumerator Testwww()
        {
            WWW tx = new WWW("https://pics5.baidu.com/feed/b64543a98226cffc7a575253c59c0299f703ea7d.jpeg?token=4b0c5a54c8067c2b5760f5dee0e25aa0");
            yield return tx;
            texture = tx.texture;
        }

        private void OnGUI()
        {

            if (texture != null)
            {
                GUI.DrawTexture(new Rect(0,0,100,100),texture);
            }
        }
    }
}